import requests


class RequestsMethod:
    # 二次封装requests
    def requests(self, method, url, headers=None, params=None, data=None, json=None):
        if method == 'post':
            return requests.request(method, url, headers=headers, data=data, json=json)

        elif method == 'get':
            return requests.request(method, url, headers=headers, params=params)

    # 获取json响应内容
    def response_json(self, method, url, headers=None, params=None, data=None, json=None):
        return self.requests(method, url, headers=headers, params=params, data=data, json=json).json()



